﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using BCCommon;
using BCTMSRESTful.Configs;
using BCService.Sim.Admin.AdminSpecificPermissionRecordService;
using BCDto.Sim.Admin.AdminSpecificPermissionRecord;

namespace BCTMSRESTful.Controllers.Management.Admin.AdminPermission
{
    /// <summary>
    /// 管理员特殊权限控制器
    /// </summary>
    [ApiExplorerSettings(GroupName = "Admin")]
    [Route("api/v1/sim/[controller]")]
    public class AdminSpecificPermissionRecordController : ManagementBaseController
    {
        private readonly IAdminSpecificPermissionRecordService adminSpecificPermissionRecordService;
      
        public AdminSpecificPermissionRecordController(IAdminSpecificPermissionRecordService adminSpecificPermissionRecordService)
        {
            this.adminSpecificPermissionRecordService = adminSpecificPermissionRecordService;
        }
      
        /// <summary>
        /// 添加管理员特殊权限记录
        /// </summary>
        /// <param name="adminSpecificPermissionRecordRequestDto">特殊权限记录信息</param>
        /// <response code="200">获取管理员特殊权限记录</response>
        /// <returns></returns>
        [HttpPost]
        [Log("添加员工特殊权限")]
        [ProducesResponseType(typeof(AdminSpecificPermissionRecordDto), 201)]
        [Obsolete]
        public IActionResult Post([FromBody]AdminSpecificPermissionRecordRequestDto adminSpecificPermissionRecordRequestDto)
        {
            var result = this.adminSpecificPermissionRecordService.Add(adminSpecificPermissionRecordRequestDto);
            return this.Created(string.Format("api/v1/sim/AdminSpecificPermissionRecord/{0}", result.AdminSpecificPermissionRecordId), result);
        }

        /// <summary>
        /// 删除管理员特殊权限记录
        /// </summary>
        /// <param name="adminId">管理员Id</param>
        /// <param name="extensionPermissionKey">管理员特殊权限Key</param>
        /// <response code="200">获取管理员特殊权限记录</response>
        /// <response code="204">无内容。</response>
        /// <returns></returns>
        [HttpDelete("{admin_id}/{extension_permission_key}")]
        [Log("删除员工特殊权限")]
        [Obsolete]
        public IActionResult Delete([FromRoute(Name = "admin_id")]long adminId,
            [FromRoute(Name = "extension_permission_key")]string extensionPermissionKey)
        {
            this.adminSpecificPermissionRecordService.Delete(adminId,extensionPermissionKey);
            return NoContent();
        }

        #region 获取管理员特殊权限记录
        /// <summary>
        /// 获取管理员特殊权限记录
        /// </summary>
        /// <response code="200">获取管理员特殊权限记录</response>
        /// <returns></returns>
        [HttpGet("{admin_id}")]
        [ProducesResponseType(typeof(IEnumerable<AdminSpecificPermissionRecordDto>), 200)]
        [Obsolete]
        public IActionResult Get([FromRoute(Name ="admin_id")]long adminId)
        {
            return this.Ok(adminSpecificPermissionRecordService.Query(adminId));
        }

        #endregion
    }
}
